//
//  Student.cpp
//  c++algorithm
//
//  Created by WuDi on 24/03/13.
//  Copyright (c) 2013 WuDi. All rights reserved.
//

#include "Student.h"


class Person
{
private:
    string name;
    string idNum;
    
public:
    
    void print();
    string getName();
    Person(string name,string idNum)
    {
        this->name = name;
        this->idNum = idNum;
    }

};

void Person::print()
{
    cout<<"Name"<<name<<endl;
    cout<<"IDNum"<<idNum<<endl;
}

string Person::getName()
{
    return name;
}

class Student : public Person
{
private:
    string major;
    int gradYear;
public:
    void print();
    void changeMajor(const string& newMajor);
    
    Student(string name,string idNum,string major,int gradYear) : Person(name,idNum)
    {
        this->major = major;
        this->gradYear = gradYear;
    }
};

void Student::print()
{
    Person::print();
    cout<<"Major: "<<major<<endl;
    cout<<"gradYear: "<<gradYear<<endl;
}

void Student::changeMajor(const string& newMajor)
{
    this->major = newMajor;
}

int Main_Student(int argc, const char * argv[])
{
    Person person("Mary","12-345");
    Student student("Joy","98-764","Math",2012);
    
    person.print();
    student.print();
    
    student.changeMajor("English");
    student.print();
    return 0;
}